﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RuleCode.Table;

namespace ERPWebDemos.Forms.Dialogs
{
    public partial class UpdateUsers : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (ValidateParams() == false)
            //{
            //    return;
            //}

            //if (!IsPostBack)
            //{
            //    BindData();
            //}
        }

        #region 数据绑定

        /// <summary>
        /// 验证参数
        /// </summary>
        /// <returns></returns>
        protected bool ValidateParams()
        {
            bool result = true;
            //result &= ((Request["type"] == "add") || (Request["type"] == "edit" && Request["recid"] != null));
            return result;
        }

        /// <summary>
        /// 绑定数据
        /// </summary>
        protected void BindData()
        {
            //if (Request["type"] == "add")
            //{
            //    UpdateButton.Text = "增加";
            //}
            //else if (Request["type"] == "edit")
            //{
            //    UpdateButton.Text = "修改";
            //    Users users = Users.Find("RECID="+Request["recid"]);
            //    if (users.Count > 0)
            //    {
            //        UserID_Input.Value = users.UserID.Value;
            //        Email_Input.Value = users.Email.Value;
            //    }
            //}
        }
        #endregion

        #region 按钮事件
        protected void UpdateButton_OnServerClick(object sender, EventArgs e)
        {         
            //if (Request["type"] == "add")
            //{
            //    Users users = Users.Find("1=2");
            //    users.New();
            //    users.UserID.Value = UserID_Input.Value;
            //    users.Email.Value = Email_Input.Value;
            //    users.Insert ();
            //}
            //else if (Request["type"] == "edit")
            //{
            //    UpdateButton.Text = "修改";
            //    Users users = Users.Find("RECID=" + Request["recid"]);
            //    if (users.Count > 0)
            //    {
            //        users.UserID.Value=UserID_Input.Value ;
            //        users.Email.Value =Email_Input.Value ;
            //        users.Modify();
            //    }
            //} 
            //ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "refresh", "<script type='text/javascript'>refreshParent();</script>", false);
        
        }
        protected void CancelButton_OnServerClick(object sender, EventArgs e)
        {
            //ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "refresh", "<script type='text/javascript'>refreshParent();</script>", false);
        }
        #endregion
    }
}
